<script type="text/javascript">
    $.CurrentNavtab.find("#batchSetAttrBtn").on("click", function() {
        var chkbox = $.CurrentNavtab.find("input[name='ids']:checked");
        
        if(chkbox.length == 0) {
            $(this).alertmsg("warn", "请选择一个地块");
            return false;
        }
        
        if(chkbox.length > 1) {
            $(this).alertmsg("warn", "请勿选择多个地块");
            return false;
        }
        var blockId = $(chkbox[0]).val();
        $(this).dialog({url:"{:U('Admin/Block/batchSetAttr')}" + "/blockId/" + blockId, title:'批量设置苗木自有属性', height:'380'});
    });
</script>
<div class="bjui-pageHeader">
    <form id="pagerForm" data-toggle="ajaxsearch" action="{:U('Admin/Block/blockList')}" method="post">
        <input type="hidden" name="pageSize" value="{$pageSize}">
        <input type="hidden" name="pageCurrent" value="{$pageCurrent}">
        <input type="hidden" name="orderField" value="{$orderField}">
        <input type="hidden" name="orderDirection" value="{$orderDirection}">
        <div class="bjui-searchBar">
            <label>地块编号：</label><input type="text" name="sn" value="{$params.sn}" class="form-control" size="20">&nbsp;
            所属基地：
            <select name="base_id" id="base_id" class="form-control" style="width:150px;">
                <option value="0">请选择</option>
                <notempty name="base">
                    <foreach name="base" item="vo" key="k">
                        <option value="{$vo.id}" <if condition="$vo['id'] eq $params['base_id']">selected="selected"</if>>{$vo.name}</option>
                    </foreach>
                </notempty>
            </select>
            <button type="submit" class="btn-default" data-icon="search">查询</button>&nbsp;
            <a class="btn btn-orange" href="javascript:;" onclick="$(this).navtab('reloadForm', true);" data-icon="undo">清空查询</a>
        </div>
    </form>
    <div style="margin:10px 0;">
        <if condition="checkRule('Admin/Block/addBlock')">
        <a class="btn btn-green" href="{:U('Admin/Block/addBlock')}" data-toggle="navtab" data-id="Admin/Block/addBlock">添加地块</a>
        </if>
        <if condition="checkRule('Admin/Block/delBlock')">
        <a class="btn btn-red" href="{:U('Admin/Block/delBlock')}" data-toggle="doajaxchecked" data-confirm-msg="确定要删除选中地块吗？" data-idname="ids" data-group="ids">批量删除</a>
        </if>
        <if condition="checkRule('Admin/Block/delAllTree')">
        <a class="btn btn-red" href="{:U('Admin/Block/delAllTree')}" data-toggle="doajaxchecked" data-confirm-msg="确定要删除选中地块下所有苗木吗？" data-idname="ids" data-group="ids">删除所有苗木</a>
        </if>
        <if condition="checkRule('Admin/Block/batchSetAttr')">
        <a class="btn btn-green" href="javascript:void(0);" id="batchSetAttrBtn">批量设置苗木自有属性</a>
        </if>
    </div>
</div>
<div class="bjui-pageContent tableContent">
    <table data-toggle="tablefixed" data-width="100%" data-nowrap="true">
        <thead>
            <tr>
                <th width="26"><input type="checkbox" class="checkboxCtrl" data-group="ids" data-toggle="icheck"></th>
                <th data-order-field="id">ID</th>
                <th>基地名称</th>
                <th data-order-field="sn">地块编号</th>
                <th data-order-field="area">地块面积(平方米)</th>
                <th>苗木总览</th>
                <th>备注说明</th>
                <th width="100">操作</th>
            </tr>
        </thead>
        <tbody>
        <notempty name="list">
            <foreach name="list" item="vo" key="k">
                <tr data-id="{$vo.id}">
                    <td><input type="checkbox" name="ids" data-toggle="icheck" value="{$vo.id}"></td>
                    <td>{$vo.id}</td>
                    <td>{$vo.base_name}</td>
                    <td>{$vo.sn}</td>
                    <td>{$vo.area}</td>
                    <td>{$vo.countInfo}</td>
                    <td>{$vo.remark}</td>
                    <td>
                        <if condition="checkRule('Admin/Block/updBlock')">
                            <a href="{:U('Admin/Block/updBlock', array('blockId' => $vo['id']))}" class="btn btn-green" data-toggle="navtab" data-id="Admin/Block/updBlock">编辑</a>
                        </if>
                        <if condition="checkRule('Admin/Block/delBlock')">
                            <a href="{:U('Admin/Block/delBlock', array('ids' => $vo['id']))}" class="btn btn-red" data-toggle="doajax" data-confirm-msg="确定要删除该地块吗？">删</a>
                        </if>
                    </td>
                </tr>
            </foreach>
        </notempty>
        </tbody>
    </table>
</div>
<div class="bjui-pageFooter">
    <div class="pages">
        <span>每页&nbsp;</span>
        <div class="selectPagesize">
            <select data-toggle="selectpicker" data-toggle-change="changepagesize">
                <option value="30" <if condition="$pageSize eq 30">selected="selected"</if>>30</option>
                <option value="60" <if condition="$pageSize eq 60">selected="selected"</if>>60</option>
                <option value="120" <if condition="$pageSize eq 120">selected="selected"</if>>120</option>
                <option value="150" <if condition="$pageSize eq 150">selected="selected"</if>>150</option>
            </select>
        </div>
        <span>&nbsp;条，共 {$total} 条</span>
    </div>
    <div class="pagination-box" data-toggle="pagination" data-total="{$total}" data-page-size="{$pageSize}" data-page-current="{$pageCurrent}"></div>
</div>